package samplegameplugin;

import gamefw.framework.Coordinate;
import gamefw.gameplugin.AbstractPlayer;
import gamefw.gameplugin.GameBoard;
import gamefw.gameplugin.PlayResult;
import gamefw.uiplugin.IInputManager;

public class SampleHumanPlayer extends AbstractPlayer {

	@Override
	public PlayResult play(GameBoard board, IInputManager inputManager) {
		
		while (true) {
			// Get a position
			Coordinate position = inputManager.getPosition();
			Coordinate logicalPosition = board.getLogicalPosition(position);
			
			// Check if the position is empty.
			try {
				if (board.getEntity(logicalPosition) == null) {
					return new PlayResult(logicalPosition);
				}
			} catch(IndexOutOfBoundsException e) {
				continue;
			}
		}
	}

}
